package com.kashow.bean.circle;

import android.text.TextUtils;

import com.bilibili.boxing.model.entity.BaseMedia;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.kashow.bean.BaseBean;

/**
 * Created by yybs on 16/12/12.
 */

public class EditItem extends BaseBean implements MultiItemEntity, Comparable<EditItem> {
    public static final int TYPE_HEAD = 1;
    public static final int TYPE_ADD_ITEM = 2;
    public static final int TYPE_ADD_SELECTOR = 3;
    public static final int TYPE_VIDEO_ITEM = 4;
    public static final int TYPE_IMAGE_ITEM = 5;
    public static final int TYPE_TEXT_ITEM = 6;

    private int itemType = 0;
    private AudioBean audio;
    private CircleItemBean mContent;
    private BaseMedia mBaseMedia;
    private ImageInfo mImageInfo;
    private MediaInfo mMediaInfo;
    private String mCircleType;
    private int position;

    public CircleItemBean getContent() {
        return mContent;
    }

    public void setContent(CircleItemBean content) {
        mContent = content;
    }

    @Override
    public int getItemType() {
        if (itemType != 0) {
            return itemType;
        }
        if (mContent == null) {
            return TYPE_ADD_ITEM;
        } else {
            String pic = mContent.getImageUrl();
            String video = mContent.getVideo();
            String text = mContent.getText();
            if (audio != null) {
                return TYPE_HEAD;
            }
            if (!TextUtils.isEmpty(video)) {
                return TYPE_VIDEO_ITEM;
            } else if (!TextUtils.isEmpty(pic)) {
                return TYPE_IMAGE_ITEM;
            } else if (!TextUtils.isEmpty(text)) {
                return TYPE_TEXT_ITEM;
            } else {
                return TYPE_ADD_ITEM;
            }
        }
    }

    public void setItemType(int itemType) {
        this.itemType = itemType;
    }

    public AudioBean getAudio() {
        return audio;
    }

    public void setAudio(AudioBean audio) {
        this.audio = audio;
    }

    public BaseMedia getBaseMedia() {
        return mBaseMedia;
    }

    public void setBaseMedia(BaseMedia mediaBean) {
        mBaseMedia = mediaBean;
    }

    public ImageInfo getImageInfo() {
        return mImageInfo;
    }

    public void setImageInfo(ImageInfo imageInfo) {
        mImageInfo = imageInfo;
    }


    public MediaInfo getMediaInfo() {
        return mMediaInfo;
    }

    public void setMediaInfo(MediaInfo mediaInfo) {
        mMediaInfo = mediaInfo;
    }

    public String getCircleType() {
        return mCircleType;
    }

    public void setCircleType(String circleType) {
        mCircleType = circleType;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    @Override
    public int compareTo(EditItem editItem) {
        return this.position - editItem.getPosition();
    }

    @Override
    public String toString() {
        return "EditItem{" +
                "itemType=" + itemType +
                ", audio=" + audio +
                ", mContent=" + mContent +
                ", mBaseMedia=" + mBaseMedia +
                ", mImageInfo=" + mImageInfo +
                ", mMediaInfo=" + mMediaInfo +
                ", mCircleType='" + mCircleType + '\'' +
                ", position=" + position +
                '}';
    }
}
